import unittest

import jsonschema

from api.ihrm_login_api import IhrmLoginApi


class TestIhrmLogin(unittest.TestCase):

    def test01_login_success(self):
        json_data = {"mobile": "13800000002", "password": "hm#qd@23!"}
        resp = IhrmLoginApi.login(json_data)
        print("登录成功", resp.json())


        #断言
        self.assertEqual(200, resp.status_code)

    # 使用全量字段校验 替换 断言
    # 校验规则
        schema = {
            "type": "object",
            "properties": {
                "success": {"const": True},
                "code": {"const": 10000},
                "data": {"type": "string"},
                "message": {"const": "登录成功"}
            },
            "required": ["success", "code", "data", "message"]
        }

        jsonschema.validate(instance=resp.json(), schema=schema)